package com.testdocs.client.version;

import java.io.Serializable;

import com.testdocs.client.validation.SelfValidating;
import com.testdocs.client.validation.SimpleConstraint;
import com.testdocs.client.validation.ValidationConstraint;

@SuppressWarnings("serial")
public class VersionInfo implements Serializable, SelfValidating {
    private String name = "";
	
	private String id = null;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public void setId(String id) {
		this.id = id;
	}

	public String getId() {
		return id;
	}
	
	@Override
	public ValidationConstraint[] selfValidate() {
		if (name == null || name.length() == 0) {
			ValidationConstraint constraint = new SimpleConstraint("Version name should be specified", "versionName");
			return new ValidationConstraint[] {constraint};
		} else if (name.length() > 256) {
			ValidationConstraint constraint = new SimpleConstraint("Version name should not be longer than 256 symbols", "versionName");
			return new ValidationConstraint[] {constraint};			
		} else {
			return null;
		}
	}

}
